/**********************init***********************/
function queryAnn_ann(page){
	sys_loading();
	var parm = $('#queryAnnForm').serialize() + (page != null ? ('&page=' + page) : '');
	var url = create_url('ann-query');
	sys_record_parm('ann',parm);
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_loading_close();
			$('#annResultList').html(result);
		}
	});
}


function edit_ann(code) {
	var parm = {'code':code};
	var url = create_url('ann-edit');
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm});
}

function deleteAnn_ann(code, title) {
	var url = create_url('ann-delete');
		$.Zebra_Dialog('要删除 《' + title + '》 吗?',{
		'type': 'question',
		'title': '警告' ,
		'buttons':[
	       {caption:'确认',callback:function() {
        	   aidExecuteAnn_ann(code, url);
	       }},
           {caption:'取消',callback:function(){}
           }]
	});
}

function aidExecuteAnn_ann(code, url) {
	var parm = {'code':code};
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_submiting_close();
			if ('success' == result) {
				queryAnn_ann();
			} else if ('deleted' == result){ 
				new $.Zebra_Dialog('你不能删除', {
				    'buttons':  false,
				    'modal': false,
				    'auto_close': 2000
				});
			} else {
				new $.Zebra_Dialog('操作失败，请刷新页面再次尝试，如果问题依然存在，请联系管理员!', {
				    'buttons':  false,
				    'modal': false,
				    'auto_close': 2000
				});
			}
		}
	});
}

/*******************************edit***********************/
function saveAnn_ann() {
	var parm = $('#editAnnForm').serialize() + '&content=' + fixJqText(Url.encode(ann_content.getData()));
	var content = fixJqText(Url.encode(ann_content.getData()));
	var url = create_url('ann-save');
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_submiting_close();
			if (result == 'success') {
				sys_msg('操作成功');
				sys_load_handle('ann');
			}else if(result == 'null_title'){
				sys_msg('标题不能为空');
			}else if(result == 'not_find'){
				sys_msg('内容不能为空');
			}else if(result == 'exits'){
				sys_msg('已审核不能修改');
			} else {
				sys_msg('操作失败');
			}
		}
	});
}

